unit IException;

interface

uses
  system.SysUtils;

type
  TException = class(Exception)
  protected
    m_ErrorCode: Integer;
    m_ErrorMessage: String;
    function GetErrorMessage: String;
  published
    property ErrorMessage: String read GetErrorMessage;
    property ErrorCode: Integer read m_ErrorCode;
  public
    constructor Create(const Details: String); overload;
    constructor Create(Code: Integer; const Details: String); overload;
    destructor Destroy; override;
  end;

implementation

constructor TException.Create(const Details: String);
begin
  inherited Create('');
  m_ErrorMessage := Details;
end;

constructor TException.Create(Code: Integer; const Details: String);
begin
  inherited Create('');
  m_ErrorCode := Code;
  m_ErrorMessage := Details;
  Message := 'Error code is ' + IntToStr(Code) + '. Details are ' + Details;
end;

destructor TException.Destroy;
begin
  inherited Destroy;
end;

function TException.GetErrorMessage: String;
begin
  if m_ErrorMessage <> '' then
    Result := Result + ' Details are: ' + m_ErrorMessage;
end;

end.
